<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日程管理系统登录页</title>
    <style>

        .ht {
            text-align: center;
            color: cadetblue;
            font-family: 幼圆, serif;
        }

        .tab {
            width: 500px;
            border: 5px solid cadetblue;
            margin: 0 auto;
            border-radius: 5px;
            font-family: 幼圆, serif;
        }

        .ltr td {
            border: 1px solid powderblue;

        }

        .ipt {
            border: 0;
            width: 50%;

        }

        .btn1 {
            border: 2px solid powderblue;
            border-radius: 4px;
            width: 60px;
            background-color: antiquewhite;

        }

        #usernameMsg, #userPwdMsg {
            color: rgb(230, 87, 51);
        }

        .buttonContainer {
            text-align: center;
        }
    </style>
    <script>
        function checkForm() {
            var b = checkUsername();
            var b1 = checkUserPwd();
            return b && b1;

        }

        function checkUsername() {
            var elementById = document.getElementById("usernameInput");
            var value = elementById.value;
            var elementById1 = document.getElementById("usernameMsg");
            var reg = /^[a-zA-Z ][a-zA-Z-0-9]{5,9}$/
            if (reg.test(value) === false) {
                elementById1.innerText = "账号格式错误！";
                return false;
            } else {
                elementById1.innerText = "账号格式正确！";
                elementById1.style.color = "green";
                return true;
            }
        }

        function checkUserPwd() {
            var elementById = document.getElementById("userPwdInput");
            var value = elementById.value;
            var elementById1 = document.getElementById("userPwdMsg");
            var reg = /^[a-zA-Z0-9 _\-@#&*]{6,12}$/;
            if (reg.test(value) === false) {
                elementById1.innerText = "密码格式错误！"
                return false;
            } else {
                elementById1.innerText = "密码格式正确！"
                elementById1.style.color = "green";
                return true;
            }
        }
    </script>
</head>
<body>
<h1 class="ht">欢迎使用日程管理系统</h1>
<h3 class="ht">请登录</h3>
<form method="post" action="/user/login" onsubmit="return checkForm()">
    <table class="tab" cellspacing="0px">
        <tr class="ltr">
            <td>请输入账号</td>
            <td>
                <input class="ipt" type="text" id="usernameInput" name="username" onblur="checkUsername()">
                <span id="usernameMsg"></span>
            </td>
        </tr>
        <tr class="ltr">
            <td>请输入密码</td>
            <td>
                <input class="ipt" type="password" id="userPwdInput" name="userPwd" onblur="checkUserPwd()">
                <span id="userPwdMsg"></span>
            </td>
        </tr>
        <tr class="ltr">
            <td colspan="2" class="buttonContainer">
                <input class="btn1" type="submit" value="登录">
                <input class="btn1" type="reset" value="重置">
                <button class="btn1"><a href="regist.html">去注册</a></button>
            </td>
        </tr>
    </table>
</form>
</body>
</html>